/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package etherblocks.mods.shooter.states.objects;

import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh;
import com.jme3.material.Material;
import com.jme3.scene.Node;
import etherblocks.engine.objects.MaterialFactory;

/**
 *
 * @author Carl
 */
public class ExplosionObject extends Node{

    public ExplosionObject(String texturePath){
        particleEmitter = new ParticleEmitter("explosion", ParticleMesh.Type.Triangle, 25);
        particleEmitter.setInWorldSpace(false);
        Material material = new Material(MaterialFactory.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
        material.setTexture("Texture", MaterialFactory.getAssetManager().loadTexture(texturePath));
        particleEmitter.setMaterial(material);
        particleEmitter.setParticlesPerSec(0);
        
        attachChild(particleEmitter);
    } 
    protected ParticleEmitter particleEmitter;
    
    public void playAnimation(){
        particleEmitter.killAllParticles();
        particleEmitter.emitAllParticles();
    }
}
